import time

import requests
from qqbot import _bot as bot


def get_news():
    """抓取dear.txt中的一句话"""
    with open("./dear.txt", "rb") as f:
        content = f.readline()
        content.decode()
    return content


content = get_news()


def get_buddy():
    # 我们先得到好友列表
    my_buddy = bot.List('buddy')
    # 生成好友字典
    buddy_dict = {i: my_buddy[i] for i in range(len(my_buddy))}
    # print(buddy_dict)

    # 好友列表
    frends_list = ["我老大"]
    buddy_list = []

    for k, v in buddy_dict.items():
        v = str(v)
        for data in frends_list:
            if data in v:
                buddy_list.append(k)
                break

    # 遍历好友列表
    for i in buddy_list:
        send_to = buddy_dict[i]
        # bot.SendTo(send_to, '金山毒霸每日一句：\n' + content)
        print(content)
        time.sleep(5)



def main():
    # 给好友群发消息
    get_buddy()


if __name__ == '__main__':
    bot.Login(['-q', "1726896917"])
    main()
